import Fuction.Select;
import Fuction.*;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws SQLException {
        Scanner sc = new Scanner(System.in);
        do {
            myMenu menu = new myMenu();
            switch (sc.nextInt()) {
                case 1:
                    while(true) {
                        menu.selectMenu();
                        switch (sc.nextInt()) {
                            case 1://显示所有公选课信息
                                JDBC c1 = new JDBC();
                                Connection connection1 = c1.JDBC();
                                Select s1 = new Select();
                                s1.selectCourse(connection1);
                                connection1.close();
                                System.out.println("输入任意数字返回主菜单：");
                                int re1=sc.nextInt();
                                break;
                            case 2://选课
                                JDBC c2 = new JDBC();
                                Connection connection2 = c2.JDBC();
                                Insert i2 = new Insert();
                                i2.insertCourse(connection2);
                                connection2.close();
                                break;
                            case 3://插入新的课程
                                JDBC c4=new JDBC();
                                Connection connection4=c4.JDBC();
                                Insert i4=new Insert();
                                i4.insertNewCourse(connection4);
                                connection4.close();
                                System.out.println("输入任意数字返回主菜单：");
                                int re4=sc.nextInt();
                                break;
                            case 4:
                                break;
                            default:
                                System.out.println("此操作无效：请重新选择");
                        }
                        break;
                    }
                    break;
                case 2://学籍
                    menu.studentMenu();
                    switch (sc.nextInt()){
                        case 1://显示学生信息
                            JDBC c1 = new JDBC();
                            Connection connection1 = c1.JDBC();
                            Select s1 = new Select();
                            s1.selectStudent(connection1);
                            connection1.close();
                            System.out.println("输入任意数字返回主菜单：");
                            int re1=sc.nextInt();
                            break;
                        case 2://；显示挂科学生
                            JDBC c2 = new JDBC();
                            Connection connection2 = c2.JDBC();
                            Select s2 = new Select();
                            s2.selectFail(connection2);
                            System.out.println("输入任意数字返回主菜单：");
                            int re2=sc.nextInt();
                            connection2.close();
                            break;
                        case 3://录入成绩
                            JDBC c3 = new JDBC();
                            Connection connection3 = c3.JDBC();
                            Insert i3=new Insert();
                            i3.insertScore(connection3);
                            connection3.close();
                            System.out.println("输入任意数字返回主菜单：");
                            int re3=sc.nextInt();
                            break;
                        case 4:
                            break;
                        default:
                            System.out.println("操作错误,已经还原到主界面");
                            break;
                    }
                    break;
                case 3:
                    return;
                default:
                    System.out.println("此操作无效：请重新选择");
            }
        }while (true);
    }
}
